from public import view_person

from pylib import models
from pylib import web

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class RemoveIdentity(web.BaseHandler):
  @web.transaction_with_retries
  @web.model_from_request
  def RemoveIdentity(self, identity):
    key = identity.person.key()
    identity.delete(request=self.request)
    return key

  @web.valid_xsrf_token_required
  def post(self):
    key = self.RemoveIdentity()
    self.internal_redirect(view_person.ViewPerson(), key)


application = webapp.WSGIApplication([('.*', RemoveIdentity)])

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
